Skip to content

feat(autocomplete): rank slash commands by most-recently-used - #29

Merged
Blankeos merged 2 commits into
mainfrom
feat/slash-mru
Aug 25, 2026
Merged

feat(autocomplete): rank slash commands by most-recently-used#29
Blankeos merged 2 commits into
mainfrom
feat/slash-mru

Conversation

@Blankeos

Copy link
Copy Markdown
Owner

Add a persistent MRU store that records executed slash commands and boosts their position in autocomplete search results using a soft-decay recency score. Empty / menus keep registry order unchanged.

Add a persistent MRU store that records executed slash commands and boosts their position in autocomplete search results using a soft-decay recency score. Empty `/` menus keep registry order unchanged.
MRU data previously lived in a standalone `slash_mru.json` file. This moves it into the `slash_mru` prefs key in `data.db`, adds automatic migration from the legacy sidecar, and ensures the popup-accept path touches MRU for commands submitted via autocomplete.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@Blankeos

Copy link
Copy Markdown
Owner Author

PR Review: feat/slash-mrumain

Merge confidence: 4.5/5

PR: #106 — feat(autocomplete): rank slash commands by most-recently-used
Commit: 9d2af7d (main is ancestor — clean fast-forward/merge)


Body (GitHub-ready)

Ranks slash-command autocomplete by most-recently-used with a soft-decay score persisted to slash_mru.json under the data dir. Empty / menus keep registry order; typed queries boost recent commands. Touches MRU on successful command execution. No schema/DB migrations.


Summary of changes

File Change
src/autocomplete/mru.rs New SlashMru store (JSON, cap 200, soft-decay ranking)
src/autocomplete/command.rs Wire MRU into search sort; touch_mru; 2 new tests
src/autocomplete/mod.rs Export mru
src/app.rs touch_mru on process_command_input; safer autocomplete fallback

Regressions?

None material. Equal-score name tie-break is already ascending (a.name.cmp(&b.name)). Empty / keeps registry order. Exact/prefix match priority unchanged.

Low residual risk:

  • Corrupt/missing slash_mru.json → start fresh (handled)
  • Persist is best-effort non-atomic fs::write (corrupt-on-crash → recovered next load)
  • Touch only when input.autocomplete is Some (fallback path won’t record MRU)

Checks run (read-only / temp worktree, current checkout untouched):

  • cargo test autocomplete::30 passed (incl. search_ranks_recently_used_first, empty_query_keeps_registry_order_even_with_mru, all mru::tests)
  • No merge conflicts vs main
  • gh pr checks / GraphQL status could not be resolved from this environment

Review correction: an earlier draft flagged a descending name tie-break; re-checked commit 9d2af7d — it is ascending. Confidence bumped accordingly.


Migrations?

No. Adds a new JSON file (~/.local/state/crabcode/slash_mru.json or $XDG_STATE_HOME/crabcode/...). Does not touch SQLite prefs schema.


Checklist before merge

  • CI green on #106 (couldn’t verify locally via gh)
  • Manual smoke: execute /compact-mode, then type /compcompact-mode ranks above compact
  • Confirm empty / still matches registry order after several touches
  • Optional: verify slash_mru.json appears under data dir after first command

Confidence bumps

Action New score
Fix name tie-break (already ascending — review false positive cleared) 4.5/5 ← current
CI green + short persist round-trip test (write → reload → score) 5/5

Current 4.5/5: feature + tests look good; remaining gap is unverified CI + no disk I/O persist test.

@Blankeos
Blankeos merged commit 2f7cb67 into main Aug 25, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant